using System;
using System.Collections.Generic;
using System.Text;

namespace Rest
{
    /// <summary>
    /// Defines how a RestCommand handles redirects
    /// </summary>
    public struct RestRedirectionPolicy
    {
        private Boolean preserveHttpTransportOnRedirect;
        private Int32 redirectLimit;

        /// <summary>
        /// The default RestRedirectionPolicy
        /// </summary>
        public static readonly RestRedirectionPolicy DefaultRestRedirectionPolicy =
            new RestRedirectionPolicy();

        /// <summary>
        /// Defines what happens when a 302 redirect is encountered.
        /// When set to true, the redirect should ensure the transport is set to
        /// Rest.Transport.RestTransport.Get
        /// </summary>
        /// <value>Defaults to false</value>
        public Boolean PreserveHttpTransportOnRedirect
        {
            get { return preserveHttpTransportOnRedirect; }
            set { preserveHttpTransportOnRedirect = value; }
        }

        /// <summary>
        /// The maximum number of redirects allowed
        /// </summary>
        public Int32 RedirectLimit
        {
            get { return redirectLimit; }
            set { redirectLimit = value; }
        }

        /// <summary>
        /// ctor : Int32
        /// </summary>
        /// <param name="redirectLimit"></param>
        public RestRedirectionPolicy(
            Int32 redirectLimit) : this(redirectLimit, false) { }

        /// <summary>
        /// ctor : Boolean, Int32
        /// </summary>
        /// <param name="redirectLimit"></param>
        /// <param name="preserveHttpTransportOnRedirect"></param>
        public RestRedirectionPolicy(
            Int32 redirectLimit, 
            Boolean preserveHttpTransportOnRedirect)
        {
            this.preserveHttpTransportOnRedirect = preserveHttpTransportOnRedirect;
            this.redirectLimit = redirectLimit;
        }
    }
}
